/*
 * @Descripttion: 
 * @Author: junhuafly
 * @Date: 2020-04-01 15:55:50
 * @LastEditors: junhuafly
 * @Email: junhuafly@163.com
 * @LastEditTime: 2020-04-08 16:46:04
 */

const {
    request
} = require('./../utils/request.js')

class Order {
    constructor() {

    }
    /**
     * 操作购物车
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    handleCart(data){
        return request[data.method]('/cart',data)
    }

    /**
     * 修改数量
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    modifyCount(data){
        return request.post('/cart/modifyQuantity',data)
    }

    /**
     * 修改购物车
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    modifyCart(data){
        return request.post('/cart/modify',data)
    }

    /**
     * 移除购物车
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    dropCart(data){
        return request.post('/cart/delete',data)
    }

    /**
     * 购物车下单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    submitOrder(data){
        return request.post('/order/placeOrder',data)
    }

    /**
     * 操作临时订单跟删除订单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    handleOrder(data){
        return request[data.method]('/order',data)
    }

    /**
     * 取消订单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    cancelOrder(data){
        return request.post('/order/cancel',data)
    }
    
    /**
     * 确认收货
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    confirmOrderFinish(data){
        return request.post('/order/receiveConfirm',data)
    }

    /**
     * 获取订单详细信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderDetail(data){
        return request.get('/order/detail',data)
    }

    /**
     * 获取订单列表信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderList(data){
        return request.post('/order/list',data)
    }

    /**
     * 获取商品的配送信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderShipWay(data){
        return request.get('/order/getShipModeList',data)
    }

    /**
     * 获取包裹信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderPackages(data){
        return request.get('/order/packages',data)
    }

    /**
     * 获取物流
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderLogistics(data){
        return request.get('/order/logistics',data)
    }

    /**
     * 获取商品优惠信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderCoupon(data){
        return request.get('/order/coupon',data)
    }

    /**
     * 修改用户地址
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    modifyAddress(data){
        return request.post('/order/address/modify',data)
    }

    /**
     * 修改订单配送方式
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    putOrderShipMode(data){
        return request.put('/order/selectShipMode',data)
    }

    /**
     * 修改优惠券
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    chooseCoupon(data){
        return request.post('/order/selectCoupon',data)
    }

    /**
     * 确认订单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    confirmOrder(data){
        return request.post('/order/confirmOrder',data)
    }

    /**
     * 创建支付单
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    createOrderPay(data){
        return request.post('/order/pay',data)
    }
    
    /**
     * 确认收货
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    confirmGoodsReceive(data){
        return request.post('/order/receiveConfirm',data)
    }

    /**
     * 评价商品
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    rateGoods(data){
        return request.post('/order/rate',data)
    }

    /**
     * 获取订单汇总信息
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryOrderSummary(data){
        return request.get('/order/summary',data)
    }
    
    /**
     * 直接购买
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    handleBuyGoods(data){
        return request.post('/order/buy',data)
    }

    // 以下是售后相关内容

    /**
     * 获取售后类型
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryAfterType(data){
        return request.get('/aftersale/aftersaleTypes',data)
    }

    /**
     * 获取售后列表
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryAfterList(data){
        return request.post('/aftersale/query',data)
    }

    /**
     * 获取售后详情
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryAfterSaleInfo(data){
        return request.get('/aftersale/get',data)
    }

    /**
     * 获取快递公司
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryExpress(data){
        return request.get('/aftersale/expresses',data)
    }

    /**
     * 获取售后地址
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryAfterSafeAddress(data){
        return request.get('/aftersale/aftersaleAddress',data)
    }

    /**
     * 退回货物
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    sendBackGoods(data){
        return request.post('/aftersale/sendBack',data)
    }

    /**
     * 获取退款理由
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    queryAfterReason(data){
        return request.get('/aftersale/reasons',data)
    }

    /**
     * 计算可退金额
     * 
     * @returns 
     * 
     * @memberOf Order
     */
    calcAmount(data){
        return request.get('/aftersale/calcRefundAmountNew',data)
    }

    /**
     * 申请售后
     * 
     * @param {any} data 
     * @returns 
     * 
     * @memberOf Order
     */
    handleAfter(data){
        return request.post('/aftersale',data)
    }
    
}

exports.orderAPI = new Order